package com.hugesoft.jxgs.activity;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;

import com.hugesoft.jxgs.R;

public class StartActivity extends Activity {
	ProgressDialog pbDialog = null;

	int fileSize;
	int downLoadFileSize;
	String fileEx, fileNa, filename;
	String fileUrl;
	private Handler mHandler = new Handler() {
		public void handleMessage(android.os.Message msg) {
			switch (msg.what) {
			default:
				gotoNextActivity();
				break;
			}
		};
	};

	@Override
	protected void onCreate(Bundle savedInstanceState) {
//		try {
//			String path = ExcelUtil.createWorkBook();
//			Util.showToast(StartActivity.this, "导出成功");
//		} catch (Exception e) {
//			Util.showToast(StartActivity.this, "导出失败");
//			e.printStackTrace();
//		}
		super.onCreate(savedInstanceState);
		if (Environment.getExternalStorageState().equals(
				Environment.MEDIA_UNMOUNTED)) {
			// sd不可用
			jump();
			return;
		}
		setContentView(R.layout.activitystart);
		mHandler.sendEmptyMessageDelayed(333, 1500);
	}

	public void jump() {
		Intent i = new Intent(getApplicationContext(), QuitDialogActivity.class);
		i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		startActivity(i);
	}

	private void gotoNextActivity() {
		SharedPreferences sPreferences = this
				.getSharedPreferences(getResources().getString(R.string.shardpreference_verified),MODE_PRIVATE);
		Intent intent = new Intent();
		if (!sPreferences.getBoolean("verified", false)) {
			intent.setClass(StartActivity.this, CheckUserVerifyActivity.class);
		} else {
			intent.setClass(StartActivity.this, LoginActivity.class);
		}
		startActivity(intent);
		this.finish();
	}

//	private void sendMsg(int flag, Object obj) {
//		Message msg = new Message();
//		msg.obj = obj;
//		msg.what = flag;
//		mHandler.sendMessage(msg);
//	}
}
